y = [x*2 for x in range(1,50) if x%5 ==0]
print(y)

y2 = []
for x in range(1,50):
    if x%5 == 0:y2.append(x*2)
print (y2)

#字典推导式
my_text = "I love you, I love sxt, I love gaoqi"
char_count = {c:my_text.count(c) for c in my_text}
print(char_count)

#课下作业，使用普通的循环实现上面字典推导式实现的字符出现次数统计
my_text2 = "I love you, I love sxt, I love gaoqi"
char_count2 = {}
for c in my_text2:
    d = {c: my_text2.count(c)}
    char_count2.update(d)
print(char_count2)

#集合推导式
b = {x for x in range(1,100) if x%9 == 0}
print(b)

#生成器推导式(生成元祖)
gnt = (x for x in range(1,100) if x%9 == 0)
# print(tuple(gnt))
for x in gnt:
    print(x,end=",")
print(tuple(gnt))